package com.a0soft.gphone.aTruffleHog.util;

import java.io.File;

import android.content.Context;
import android.content.SharedPreferences;
import android.hardware.Sensor;
import android.os.Environment;

public class Wrapper {
    private static final String LOG_TAG = Wrapper.class.getSimpleName();
    
	public static File
	GetExternalFilesDir(Context ctx, String strType)
	{
		if (MiscUtil.GetSDKVersion() >= 8) {
			return SDK8.GetInstance().GetExternalFilesDir(ctx, strType);
		}
		
		File fDir = Environment.getExternalStorageDirectory();
		String str = String.format("/Android/data/%s/files", ctx.getPackageName());
		if (strType != null) {
			str += "/";
			str += strType;
		}
		fDir = new File(fDir, str);
		if (!fDir.exists())
			fDir.mkdirs();
		if (fDir.exists())
			return fDir;
		return null;
	}
    
    public static void 
    SharedPreferencesEditorApply(SharedPreferences.Editor ed)
    {
        if (MiscUtil.GetSDKVersion() >= 9) {
            SDK9.GetInstance().SharedPreferencesEditor_Apply(ed);
        }
        else {
            if (!ed.commit()) {
                aDebug.e(LOG_TAG, "failed to commit!");
            }
        }
    }
    
    public static int
    GetSensorMinDelay(Sensor oSensor)
    {
        int returnVal = -1;
        if((MiscUtil.GetSDKVersion() >= 9) &&
           (oSensor != null)) {
            returnVal = SDK9.GetInstance().Sensor_GetMinDelay(oSensor);
        }
        return returnVal;
    }
}
